<!DOCTYPE html>
<html>
<head>
  <title>ServiceWorker</title>
  <meta charset="utf-8">
  <link rel="stylesheet" href="./styles/main.css">
</head>
<body>
  <h3>Image Show</h3>
  <!-- <ul>
      <li>浏览器是否支持：<span id="isSupport"></span></li>
      <li>service worker是否注册成功：<span id="isSuccess"></span></li>
      <li>当前注册状态：<span id="state"></span></li>
      <li>当前service worker状态：<span id="swState"></span></li>
  </ul> -->
  <p><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533112206553&di=8125ced499b0478819dce454be74fbcd&imgtype=0&src=http%3A%2F%2Fh.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F267f9e2f07082838304837cfb499a9014d08f1a0.jpg"></p>
  <p><img src="https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=82f1640b19ce36d3bd0485300af23a24/fcfaaf51f3deb48f5510390ffc1f3a292cf578e2.jpg"></p>
  <p><img src="./images/bg03.jpg"></p>
  <p><img src="./images/bg04.jpg"></p>
</body>
<script src="./script/jquery.min.js"></script>
<script>
  $.get('https://github.com/robinson911/robinson911/blob/master/ljweibo.json',
    function(res) {
      console.debug('suc res: ', res);
    });
</script>
<script>
  if ('serviceWorker' in navigator) {

    // 开始注册service workers
    navigator.serviceWorker.register('/demo/ServiceWorker.js', {
      scope: '/demo/'
    })// .then(function (registration) {
    //   $('#isSuccess').text('注册成功');

    //   var serviceWorker;
    //   if (registration.installing) {
    //     serviceWorker = registration.installing;
    //     $('#state').text('installing');
    //   } else if (registration.waiting) {
    //     serviceWorker = registration.waiting;
    //     $('#state').text('waiting');
    //   } else if (registration.active) {
    //     serviceWorker = registration.active;
    //     $('#state').text('active');
    //   }
    //   if (serviceWorker) {
    //     $('#swState').text(serviceWorker.state);
    //     serviceWorker.addEventListener('statechange', function (e) {
    //       $('#swState').append('&emsp;状态变化为' + e.target.state);
    //     });
    //   }
    // }).catch (function (error) {
    //   $('#isSuccess').text('注册没有成功');
    // });
  } else {
    // $('#isSupport').text('不支持');
  }
</script>
</html>